﻿using System;
using Identity.Dto;

namespace Coder.Workflow.ViewModel
{
    public class ProcessInstanceViewData
    {
        public ProcessInstanceViewData()
        {
        }

        public ProcessInstanceViewData(ProcessInstance instance)
        {
            if (instance == null) throw new ArgumentNullException(nameof(instance));
            Id = instance.Id;
            Status = instance.Status;
            FinishTime = instance.FinishTime;
            CreateTime = instance.CreateTime;
            if (instance.User != null)
                User = new UserDto(instance.User);
            if (WorkProcess == null)
                WorkProcess = new WorkProcessViewData(instance.WorkProcess);
            Number = instance.Number;
        }

        public int Id { get; set; }
        public WorkProcessViewData WorkProcess { get; set; }

        public ProcessInstanceStatus Status { get; set; }

        public DateTimeOffset? FinishTime { get; set; }

        public DateTimeOffset CreateTime { get; set; }

        public UserDto User { get; set; }

        public string Number { get; set; }
    }
}